

const { resolve } = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

/**
 * 
 * module：模块
 * 
 * 
 */

module.exports = {
    entry: "./src/index.js",
    output: {
        filename: "[name].js",
        path: resolve(__dirname, "build"),
    },
    module: {
        rules: [
            // loader的配置
            {
                test: /\.css$/,
                // 多个loader用use
                use: ["style-loader", "css-loader"]
            },
            {
                tese: /\.js$/,
                // 排除某些文件
                exclude: /node_module/,
                // 只检查src下面的文件
                include: resolve(__dirname, "src"),
                // 优先执行   pre/post/（无），优先执行/延迟执行/默认排序执行
                enforce: "pre",
                // 单个loader使用loader,
                loader: "eslint-loader",

            },
            {
                // 以下配置只会生效一个
                oneOf: []
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin(),
        new CleanWebpackPlugin()
    ],
    mode: "development"
}